﻿#include "imageitem.h"

#include <QPixmap>

ImageItem::ImageItem(QObject *parent) : QObject(parent)
{

}

QVariant ImageItem::data(int col)
{
    if(col == CN_PATH){
        return file();
    }else if(col == CN_INFO){
        QSize s = size();
        return QString("%1 * %2").arg(s.width()).arg(s.height());
    }else if(col == CN_IMAGE) {
        QImage img = m_image.scaled(300,300,Qt::KeepAspectRatio,Qt::SmoothTransformation);
        return QPixmap::fromImage(img);
    }
    return QVariant();
}

bool ImageItem::setData(int col, QVariant value)
{
    return true;
}
